home *** CD-ROM | disk | FTP | other *** search
- // mfc_mdiDoc.cpp : implementation of the CMfc_mdiDoc class
- //
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // DataViews Multiple Document Inteface (MDI) example program.
- //
- // CMfc_mdiDoc class
- // -----------------
- //
- // The simplest way to imagine integrating DataViews into the MFC Document-
- // View architecture is to first think of the DataViews view file as really
- // belonging the CDocument (and with that, an unfortunate clash of nomencla-
- // ture!), and the DataView's screen and drawport as belonging more naturally
- // with the MFC CView.
- //
- // With that as a starting point then, CMfc_mdiDoc is responsible for the
- // creation (TviLoad) and destruction (TviDestroy) of DataViews views, filling
- // requests for the view from the MFC CView object (GetDVview, done as an
- // inline in the .h file), and finally, for notifying the CView that a Data-
- // Views view file has been succesfully loaded for it to display.
- //
- /////////////////////////////////////////////////////////////////////////////
-
-
- #include "stdafx.h"
- #include "mfc_mdi.h"
-
- #include "mfc_mdiDoc.h"
- #include "mfc_mdiView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfc_mdiDoc
-
- IMPLEMENT_DYNCREATE(CMfc_mdiDoc, CDocument)
-
- BEGIN_MESSAGE_MAP(CMfc_mdiDoc, CDocument)
- //{{AFX_MSG_MAP(CMfc_mdiDoc)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfc_mdiDoc construction/destruction
-
-
- /////////////////////////////////////////////////////////////////////////////
- //
- CMfc_mdiDoc::CMfc_mdiDoc()
- : m_DVview(0)
- {
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // Destroy the DataViews view...
- //
- CMfc_mdiDoc::~CMfc_mdiDoc()
- {
- if(m_DVview)
- TviDestroy(m_DVview);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfc_mdiDoc serialization
-
- void CMfc_mdiDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfc_mdiDoc diagnostics
-
- #ifdef _DEBUG
- void CMfc_mdiDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
-
- void CMfc_mdiDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfc_mdiDoc commands
-
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // OnOpenDocument
- //
- BOOL CMfc_mdiDoc::OnOpenDocument(LPCTSTR lpszPathName)
- {
- //
- // Load from disk the DataViews view file...
- //
- if((m_DVview = TviLoad((char*)lpszPathName)))
- {
- // ...and then getting the CView associated with this document...
- POSITION pos = GetFirstViewPosition();
- CMfc_mdiView* pView = (CMfc_mdiView*)GetNextView(pos);
- ASSERT(pView);
-
- // ...and then finally telling it to display the DataViews view.
- return pView->InitDv(m_DVview);
- }
- return FALSE;
- }
-